package com.wuad.platformwuad.module.study.stringMethods;

import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;

/**
 * 将字符串按照指定字符拆分 为List
 *
 * @author ：Wuad
 * @date ：Created in 2021/3/18 15:42
 * @description :
 */
public class SplitMethodDemo {
    public static void main(String[] args) {
        String ss = "q,w,e,r,t,y,";
        List<String> list = StringToArrayList(ss, ",");
        System.out.println(StringToArrayList(ss, ","));
        if (list.contains("y")) {
            System.out.println("1111");
        } else {
            System.out.println("2222");
        }
//        String[] sss = ss.split(",");
//        if ("q".c(sss)){
//
//        }
    }

    public static List<String> StringToArrayList(String str, String separator) {
        List<String> arr = new ArrayList<String>();
        if ((str == null) || (separator == null)) {
            return arr;
        }
        StringTokenizer st = new StringTokenizer(str, separator);
        while (st.hasMoreTokens()) {
            arr.add(st.nextToken());
        }
        return arr;
    }
}
